package com.example.mall.controller;

import com.example.mall.param.BasePageParam;
import com.example.mall.param.brands.AddBrandsParam;
import com.example.mall.param.brands.BrandsNameParam;
import com.example.mall.param.brands.EditBrandsParam;
import com.example.mall.param.brands.FindBrandsParam;
import com.example.mall.service.BrandsService;
import com.example.mall.util.ResultVo;
import com.example.mall.vo.brands.FindByIdVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
@RestController
@RequestMapping("/brands")
public class BrandsController {

    @Autowired
    private BrandsService brandsService;

    @PostMapping("/edit")
    @ApiOperation(value = "编辑品牌")
    public ResultVo edit(@RequestBody EditBrandsParam param){
        Integer result = brandsService.edit(param);
        return ResultVo.success(result);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加品牌")
    public ResultVo add(@RequestBody AddBrandsParam param){
        Integer result = brandsService.add(param);
        return ResultVo.success(result);
    }

    @PostMapping("/find")
    @ApiOperation(value = "查找品牌")
    public ResultVo BrandsFindById(@RequestBody FindBrandsParam param){
        FindByIdVo result = brandsService.BrandsFindById(param);
        return ResultVo.success(result);
    }

    @PostMapping("/findAll")
    @ApiOperation(value = "查找全部品牌")
    public ResultVo BrandsFindAll(@RequestBody BasePageParam param){
        HashMap result = brandsService.BrandsFindAll(param);
        return ResultVo.success(result);
    }

    @PostMapping("/findByFlow")
    @ApiOperation(value = "查找热门品牌")
    public ResultVo findByFlow(@RequestBody BasePageParam param){
        HashMap result = brandsService.findByFlow(param);
        return ResultVo.success(result);
    }

    @PostMapping("/findByBrandsName")
    @ApiOperation(value = "品牌名模糊查询")
    public ResultVo findByBrandsName(@RequestBody BrandsNameParam param){
        HashMap result = brandsService.findByBrandsName(param);
        return ResultVo.success(result);
    }
}
